package com.revai.engine.basic.controller;

import com.revai.engine.common.api.CommonResult;

import cn.hutool.json.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.revai.engine.basic.service.TableService;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by CodeGenerator on 2024/01/11
 */
@Api(tags = "FormController", description = "获取项目基础数据接口")
@Controller
@RequestMapping("${server.api-path}/form")
public class FormController {
    @Resource
    private TableService tableService;

    @ApiOperation(value = "获取枚举数据接口")
    @RequestMapping(value = "/get_values", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Object> getValues(@RequestBody JSONObject requestBody) throws Exception {
        Object res = tableService.getTableValues(requestBody);
        return CommonResult.success(res);
    }

    @ApiOperation(value = "根据ids获取数据接口")
    @RequestMapping(value = "/getForeignValues", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Object> getForeignValues(@RequestBody JSONObject requestBody) throws Exception {
        List<Object> res = tableService.getForeignValues(requestBody);
        return CommonResult.success(res);
    }
}
